package com.aldd.mapper;

import com.aldd.entity.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DeptMapper {
    //查询全部
    @Select("select dept_id deptId,dept_name deptName from dept")
    List<Dept> selectAllDept();

    //根据id查询
    @Select("select dept_id deptId,dept_name deptName from dept where dept_id = #{id}")
    Dept selectDeptById(int id);

    //根据id删除
    @Delete("delete from dept where dept_id = #{id}")
    int deleteDeptById(int id);

    //添加
    @Insert("insert into dept (dept_name) values (#{deptName})")
    void insertDept(Dept dept);

    //修改
    @Update("update dept set dept_name = #{deptName} where dept_id = #{deptId}")
    void updateDept(Dept dept);
}
